package xyz.yuzegod.megawalls.classes.normal.dreadlord;

import org.bukkit.entity.Player;
import xyz.yuzegod.megawalls.MegaWalls;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;
import xyz.yuzegod.megawalls.util.PlayerUtils;
import xyz.yuzegod.megawalls.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class SecondSkill extends Skill
{
    public SecondSkill(final Classes classes) {
        super("噬魂者", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 0.14;
            }
            case 2: {
                return 0.18;
            }
            case 3: {
                return 0.2;
            }
            default: {
                return 0.14;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7攻击时有§a" + StringUtils.percent(this.getAttribute(level)) + "§7几率恢复3点饥饿值");
            lore.add("   §7以及4点生命。");
            lore.add(" ");
            lore.add("§7冷却时间:§a3秒");
            return lore;
        }
        lore.add(" §8▪ §7攻击时有§8" + StringUtils.percent(this.getAttribute(level - 1)) + " ➜ §a" + StringUtils.percent(this.getAttribute(level)) + "§7几率恢复3点饥饿值");
        lore.add("   §7以及2点生命。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill2Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill2Level();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        if (MegaWalls.getRandom().nextInt(100) <= this.getAttribute(kitStats.getSkill2Level()) * 100.0) {
            final Player player = gamePlayer.getPlayer();
            gamePlayer.sendMessage("§e你的噬魂者技能恢复了你3点饥饿值和2点生命！");
            PlayerUtils.food(player, 3);
            PlayerUtils.heal(player, 3.0);
        }
        return true;
    }
}
